import { onMounted, onUnmounted, watch } from 'vue'
import { useSwipe } from '@/utils/useSwipe'

export function useSwipeHandlers(callback: () => void) {
	return;
  // useSwipecallback
  const { handleTouchStart, handleTouchMove, handleTouchEnd } = useSwipe(callback)

  const setupListeners = () => {
    // 
    cleanupListeners()
    window.addEventListener('touchstart', handleTouchStart)
    window.addEventListener('touchmove', handleTouchMove, { passive: false })
    window.addEventListener('touchend', handleTouchEnd)
  }

  const cleanupListeners = () => {
    window.removeEventListener('touchstart', handleTouchStart)
    window.removeEventListener('touchmove', handleTouchMove)
    window.removeEventListener('touchend', handleTouchEnd)
  }

  // 
  onMounted(setupListeners)

  // 
  onUnmounted(cleanupListeners)

  // callback，
  watch(
    () => callback,
    () => {
      debugger
      setupListeners()
    },
  )

  return { setupListeners, cleanupListeners }
}
